﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using ViennaAdvantage.Process;
using VAdvantage.Classes;
//using ViennaAdvantage.Model;
using VAdvantage.DataBase;
using VAdvantage.SqlExec;
using System.Data;
using System.Data.SqlClient;
using VAdvantage.Logging;
using VAdvantage.Utility;
using VAdvantage.Report;
//using VAdvantage.Controller;
using VAdvantage.Model;
using VAdvantage.Grids;

namespace VAdvantage.Model
{
    public class CalloutContractProduct : CalloutEngine
    {
        public String ContractProduct(Ctx ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
        {
            if (value == DBNull.Value || value == null || value.ToString() == "" || Util.GetValueOfInt(value) == 0)
            {
                return "";
            }

            int M_Product_ID = Util.GetValueOfInt(mTab.GetValue("M_Proudct_ID"));
            if (M_Product_ID != 0)
            {
                if (Util.GetValueOfBool(value))
                {
                    mTab.SetValue("PriceList", 0);
                    mTab.SetValue("PriceLimit", 0);
                    mTab.SetValue("PriceActual", 0);
                    mTab.SetValue("PriceEntered", 0);
                }
            }
            //DateTime SDate = (DateTime)(mTab.GetValue("StartDate"));
            //DateTime Edate = (DateTime)(mTab.GetValue("EndDate"));
            //int frequency = Util.GetValueOfInt(mTab.GetValue("C_Frequency_ID"));

            //string Sql = "Select NoOfDays from C_Frequency where C_Frequency_ID=" + frequency;
            //int days = Util.GetValueOfInt(DB.ExecuteScalar(Sql, null, null));
            //int totaldays = (Edate - SDate).Days;
            //int count = totaldays / days;
            //mTab.SetValue("TotalInvoice", count);
            

            return "";
        }
    }
}
